<!DOCTYPE html><html><head>
<title>struct::graph_v1 - Tcl Data Structures</title>
<style type="text/css"><!--
    HTML {
	background: 	#FFFFFF;
	color: 		black;
    }
    BODY {
	background: 	#FFFFFF;
	color:	 	black;
    }
    DIV.doctools {
	margin-left:	10%;
	margin-right:	10%;
    }
    DIV.doctools H1,DIV.doctools H2 {
	margin-left:	-5%;
    }
    H1, H2, H3, H4 {
	margin-top: 	1em;
	font-family:	sans-serif;
	font-size:	large;
	color:		#005A9C;
	background: 	transparent;
	text-align:		left;
    }
    H1.doctools_title {
	text-align: center;
    }
    UL,OL {
	margin-right: 0em;
	margin-top: 3pt;
	margin-bottom: 3pt;
    }
    UL LI {
	list-style: disc;
    }
    OL LI {
	list-style: decimal;
    }
    DT {
	padding-top: 	1ex;
    }
    UL.doctools_toc,UL.doctools_toc UL, UL.doctools_toc UL UL {
	font:		normal 12pt/14pt sans-serif;
	list-style:	none;
    }
    LI.doctools_section, LI.doctools_subsection {
	list-style: 	none;
	margin-left: 	0em;
	text-indent:	0em;
	padding: 	0em;
    }
    PRE {
	display: 	block;
	font-family:	monospace;
	white-space:	pre;
	margin:		0%;
	padding-top:	0.5ex;
	padding-bottom:	0.5ex;
	padding-left:	1ex;
	padding-right:	1ex;
	width:		100%;
    }
    PRE.doctools_example {
	color: 		black;
	background: 	#f5dcb3;
	border:		1px solid black;
    }
    UL.doctools_requirements LI, UL.doctools_syntax LI {
	list-style: 	none;
	margin-left: 	0em;
	text-indent:	0em;
	padding:	0em;
    }
    DIV.doctools_synopsis {
	color: 		black;
	background: 	#80ffff;
	border:		1px solid black;
	font-family:	serif;
	margin-top: 	1em;
	margin-bottom: 	1em;
    }
    UL.doctools_syntax {
	margin-top: 	1em;
	border-top:	1px solid black;
    }
    UL.doctools_requirements {
	margin-bottom: 	1em;
	border-bottom:	1px solid black;
    }
--></style>
</head>
<!-- Generated from file 'graph1.man' by tcllib/doctools with format 'html'
   -->
<!-- Copyright &amp;copy; 2002 Andreas Kupries &amp;lt;andreas_kupries@users.sourceforge.net&amp;gt;
   -->
<!-- struct::graph_v1.n
   -->
<body><hr> [
   <a href="../../../../../../../../home">Tcllib Home</a>
&#124; <a href="../../../../toc.html">Main Table Of Contents</a>
&#124; <a href="../../../toc.html">Table Of Contents</a>
&#124; <a href="../../../../index.html">Keyword Index</a>
&#124; <a href="../../../../toc0.html">Categories</a>
&#124; <a href="../../../../toc1.html">Modules</a>
&#124; <a href="../../../../toc2.html">Applications</a>
 ] <hr>
<div class="doctools">
<h1 class="doctools_title">struct::graph_v1(n) 1.2.1 tcllib &quot;Tcl Data Structures&quot;</h1>
<div id="name" class="doctools_section"><h2><a name="name">Name</a></h2>
<p>struct::graph_v1 - Create and manipulate directed graph objects</p>
</div>
<div id="toc" class="doctools_section"><h2><a name="toc">Table Of Contents</a></h2>
<ul class="doctools_toc">
<li class="doctools_section"><a href="#toc">Table Of Contents</a></li>
<li class="doctools_section"><a href="#synopsis">Synopsis</a></li>
<li class="doctools_section"><a href="#section1">Description</a></li>
<li class="doctools_section"><a href="#section2">Bugs, Ideas, Feedback</a></li>
<li class="doctools_section"><a href="#keywords">Keywords</a></li>
<li class="doctools_section"><a href="#category">Category</a></li>
<li class="doctools_section"><a href="#copyright">Copyright</a></li>
</ul>
</div>
<div id="synopsis" class="doctools_section"><h2><a name="synopsis">Synopsis</a></h2>
<div class="doctools_synopsis">
<ul class="doctools_requirements">
<li>package require <b class="pkgname">Tcl 8.2</b></li>
<li>package require <b class="pkgname">struct::graph <span class="opt">?1.2.1?</span></b></li>
</ul>
<ul class="doctools_syntax">
<li><a href="#1"><b class="cmd">graphName</b> <i class="arg">option</i> <span class="opt">?<i class="arg">arg arg ...</i>?</span></a></li>
<li><a href="#2"><i class="arg">graphName</i> <b class="method">destroy</b></a></li>
<li><a href="#3"><i class="arg">graphName</i> <b class="method">arc append</b> <i class="arg">arc</i> <span class="opt">?-key <i class="arg">key</i>?</span> <i class="arg">value</i></a></li>
<li><a href="#4"><i class="arg">graphName</i> <b class="method">arc delete</b> <i class="arg">arc</i> <span class="opt">?<i class="arg">arc</i> ...?</span></a></li>
<li><a href="#5"><i class="arg">graphName</i> <b class="method">arc exists</b> <i class="arg">arc</i></a></li>
<li><a href="#6"><i class="arg">graphName</i> <b class="method">arc get</b> <i class="arg">arc</i> <span class="opt">?-key <i class="arg">key</i>?</span></a></li>
<li><a href="#7"><i class="arg">graphName</i> <b class="method">arc getall</b> <i class="arg">arc</i></a></li>
<li><a href="#8"><i class="arg">graphName</i> <b class="method">arc keys</b> <i class="arg">arc</i></a></li>
<li><a href="#9"><i class="arg">graphName</i> <b class="method">arc keyexists</b> <i class="arg">arc</i> <span class="opt">?-key <i class="arg">key</i>?</span></a></li>
<li><a href="#10"><i class="arg">graphName</i> <b class="method">arc insert</b> <i class="arg">start</i> <i class="arg">end</i> <span class="opt">?<i class="arg">child</i>?</span></a></li>
<li><a href="#11"><i class="arg">graphName</i> <b class="method">arc lappend</b> <i class="arg">arc</i> <span class="opt">?-key <i class="arg">key</i>?</span> <i class="arg">value</i></a></li>
<li><a href="#12"><i class="arg">graphName</i> <b class="method">arc set</b> <i class="arg">arc</i> <span class="opt">?-key <i class="arg">key</i>?</span> <span class="opt">?<i class="arg">value</i>?</span></a></li>
<li><a href="#13"><i class="arg">graphName</i> <b class="method">arc source</b> <i class="arg">arc</i></a></li>
<li><a href="#14"><i class="arg">graphName</i> <b class="method">arc target</b> <i class="arg">arc</i></a></li>
<li><a href="#15"><i class="arg">graphName</i> <b class="method">arc unset</b> <i class="arg">arc</i> <span class="opt">?-key <i class="arg">key</i>?</span></a></li>
<li><a href="#16"><i class="arg">graphName</i> <b class="method">arcs</b> <span class="opt">?-key <i class="arg">key</i>?</span> <span class="opt">?-value <i class="arg">value</i>?</span> <span class="opt">?-in|-out|-adj|-inner|-embedding <i class="arg">nodelist</i>?</span></a></li>
<li><a href="#17"><i class="arg">graphName</i> <b class="method">node append</b> <i class="arg">node</i> <span class="opt">?-key <i class="arg">key</i>?</span> <i class="arg">value</i></a></li>
<li><a href="#18"><i class="arg">graphName</i> <b class="method">node degree</b> <span class="opt">?-in|-out?</span> <i class="arg">node</i></a></li>
<li><a href="#19"><i class="arg">graphName</i> <b class="method">node delete</b> <i class="arg">node</i> <span class="opt">?<i class="arg">node</i> ...?</span></a></li>
<li><a href="#20"><i class="arg">graphName</i> <b class="method">node exists</b> <i class="arg">node</i></a></li>
<li><a href="#21"><i class="arg">graphName</i> <b class="method">node get</b> <i class="arg">node</i> <span class="opt">?-key <i class="arg">key</i>?</span></a></li>
<li><a href="#22"><i class="arg">graphName</i> <b class="method">node getall</b> <i class="arg">node</i></a></li>
<li><a href="#23"><i class="arg">graphName</i> <b class="method">node keys</b> <i class="arg">node</i></a></li>
<li><a href="#24"><i class="arg">graphName</i> <b class="method">node keyexists</b> <i class="arg">node</i> <span class="opt">?-key <i class="arg">key</i>?</span></a></li>
<li><a href="#25"><i class="arg">graphName</i> <b class="method">node insert</b> <span class="opt">?<i class="arg">child</i>?</span></a></li>
<li><a href="#26"><i class="arg">graphName</i> <b class="method">node lappend</b> <i class="arg">node</i> <span class="opt">?-key <i class="arg">key</i>?</span> <i class="arg">value</i></a></li>
<li><a href="#27"><i class="arg">graphName</i> <b class="method">node opposite</b> <i class="arg">node</i> <i class="arg">arc</i></a></li>
<li><a href="#28"><i class="arg">graphName</i> <b class="method">node set</b> <i class="arg">node</i> <span class="opt">?-key <i class="arg">key</i>?</span> <span class="opt">?<i class="arg">value</i>?</span></a></li>
<li><a href="#29"><i class="arg">graphName</i> <b class="method">node unset</b> <i class="arg">node</i> <span class="opt">?-key <i class="arg">key</i>?</span></a></li>
<li><a href="#30"><i class="arg">graphName</i> <b class="method">nodes</b> <span class="opt">?-key <i class="arg">key</i>?</span> <span class="opt">?-value <i class="arg">value</i>?</span> <span class="opt">?-in|-out|-adj|-inner|-embedding <i class="arg">nodelist</i>?</span></a></li>
<li><a href="#31"><i class="arg">graphName</i> <b class="method">get</b> <span class="opt">?-key <i class="arg">key</i>?</span></a></li>
<li><a href="#32"><i class="arg">graphName</i> <b class="method">getall</b></a></li>
<li><a href="#33"><i class="arg">graphName</i> <b class="method">keys</b></a></li>
<li><a href="#34"><i class="arg">graphName</i> <b class="method">keyexists</b> <span class="opt">?-key <i class="arg">key</i>?</span></a></li>
<li><a href="#35"><i class="arg">graphName</i> <b class="method">set</b> <span class="opt">?-key <i class="arg">key</i>?</span> <span class="opt">?<i class="arg">value</i>?</span></a></li>
<li><a href="#36"><i class="arg">graphName</i> <b class="method">swap</b> <i class="arg">node1</i> <i class="arg">node2</i></a></li>
<li><a href="#37"><i class="arg">graphName</i> <b class="method">unset</b> <span class="opt">?-key <i class="arg">key</i>?</span></a></li>
<li><a href="#38"><i class="arg">graphName</i> <b class="method">walk</b> <i class="arg">node</i> <span class="opt">?-order <i class="arg">order</i>?</span> <span class="opt">?-type <i class="arg">type</i>?</span> <span class="opt">?-dir <i class="arg">direction</i>?</span> -command <i class="arg">cmd</i></a></li>
</ul>
</div>
</div>
<div id="section1" class="doctools_section"><h2><a name="section1">Description</a></h2>
<p>The <b class="cmd">::struct::graph</b> command creates a new graph object with an
associated global Tcl command whose name is <i class="arg">graphName</i>.  This
command may be used to invoke various operations on the graph.  It has
the following general form:</p>
<dl class="doctools_definitions">
<dt><a name="1"><b class="cmd">graphName</b> <i class="arg">option</i> <span class="opt">?<i class="arg">arg arg ...</i>?</span></a></dt>
<dd><p><i class="arg">Option</i> and the <i class="arg">arg</i>s determine the exact behavior of the
command.</p></dd>
</dl>
<p>A directed graph is a structure containing two collections of
elements, called <em>nodes</em> and <em>arcs</em> respectively, together
with a relation (&quot;connectivity&quot;) that places a general structure upon
the nodes and arcs.</p>
<p>Each arc is connected to two nodes, one of which is called the
<em>source</em> and the other the <em>target</em>. This imposes a
direction upon the arc, which is said to go from the source to the
target. It is allowed that source and target of an arc are the same
node. Such an arc is called a <em>loop</em>. Whenever a node is source
or target of an arc both are said to be <em>adjacent</em>. This extends
into a relation between nodes, i.e. if two nodes are connected through
at least one arc they are said to be <em>adjacent</em> too.</p>
<p>Each node can be the source and target for any number of arcs. The
former are called the <em>outgoing arcs</em> of the node, the latter
the <em>incoming arcs</em> of the node. The number of edges in either
set is called the <em>in-</em> resp. the <em>out-degree</em> of the node.</p>
<p>In addition to maintaining the node and arc relationships, this graph
implementation allows any number of keyed values to be associated with
each node and arc.</p>
<p>The following commands are possible for graph objects:</p>
<dl class="doctools_definitions">
<dt><a name="2"><i class="arg">graphName</i> <b class="method">destroy</b></a></dt>
<dd><p>Destroy the graph, including its storage space and associated command.</p></dd>
<dt><a name="3"><i class="arg">graphName</i> <b class="method">arc append</b> <i class="arg">arc</i> <span class="opt">?-key <i class="arg">key</i>?</span> <i class="arg">value</i></a></dt>
<dd><p>Appends a <i class="arg">value</i> to one of the keyed values associated with an
<i class="arg">arc</i>. If no <i class="arg">key</i> is specified, the key <b class="const">data</b> is
assumed.</p></dd>
<dt><a name="4"><i class="arg">graphName</i> <b class="method">arc delete</b> <i class="arg">arc</i> <span class="opt">?<i class="arg">arc</i> ...?</span></a></dt>
<dd><p>Remove the specified arcs from the graph.</p></dd>
<dt><a name="5"><i class="arg">graphName</i> <b class="method">arc exists</b> <i class="arg">arc</i></a></dt>
<dd><p>Return true if the specified <i class="arg">arc</i> exists in the graph.</p></dd>
<dt><a name="6"><i class="arg">graphName</i> <b class="method">arc get</b> <i class="arg">arc</i> <span class="opt">?-key <i class="arg">key</i>?</span></a></dt>
<dd><p>Return the value associated with the key <i class="arg">key</i> for the <i class="arg">arc</i>.
If no key is specified, the key <b class="const">data</b> is assumed.</p></dd>
<dt><a name="7"><i class="arg">graphName</i> <b class="method">arc getall</b> <i class="arg">arc</i></a></dt>
<dd><p>Returns a serialized list of key/value pairs (suitable for use with
[<b class="cmd">array set</b>]) for the <i class="arg">arc</i>.</p></dd>
<dt><a name="8"><i class="arg">graphName</i> <b class="method">arc keys</b> <i class="arg">arc</i></a></dt>
<dd><p>Returns a list of keys for the <i class="arg">arc</i>.</p></dd>
<dt><a name="9"><i class="arg">graphName</i> <b class="method">arc keyexists</b> <i class="arg">arc</i> <span class="opt">?-key <i class="arg">key</i>?</span></a></dt>
<dd><p>Return true if the specified <i class="arg">key</i> exists for the <i class="arg">arc</i>. If no
<i class="arg">key</i> is specified, the key <b class="const">data</b> is assumed.</p></dd>
<dt><a name="10"><i class="arg">graphName</i> <b class="method">arc insert</b> <i class="arg">start</i> <i class="arg">end</i> <span class="opt">?<i class="arg">child</i>?</span></a></dt>
<dd><p>Insert an arc named <i class="arg">child</i> into the graph beginning at the node
<i class="arg">start</i> and ending at the node <i class="arg">end</i>. If the name of the new
arc is not specified the system will generate a unique name of the
form <em>arc</em><i class="arg">x</i>.</p></dd>
<dt><a name="11"><i class="arg">graphName</i> <b class="method">arc lappend</b> <i class="arg">arc</i> <span class="opt">?-key <i class="arg">key</i>?</span> <i class="arg">value</i></a></dt>
<dd><p>Appends a <i class="arg">value</i> (as a list) to one of the keyed values
associated with an <i class="arg">arc</i>.  If no <i class="arg">key</i> is specified, the key
<b class="const">data</b> is assumed.</p></dd>
<dt><a name="12"><i class="arg">graphName</i> <b class="method">arc set</b> <i class="arg">arc</i> <span class="opt">?-key <i class="arg">key</i>?</span> <span class="opt">?<i class="arg">value</i>?</span></a></dt>
<dd><p>Set or get one of the keyed values associated with an arc.  If no key
is specified, the key <b class="const">data</b> is assumed.  Each arc that is
added to a graph has the empty string assigned to the key
<b class="const">data</b> automatically.  An arc may have any number of keyed
values associated with it.  If <i class="arg">value</i> is not specified, this
command returns the current value assigned to the key; if <i class="arg">value</i>
is specified, this command assigns that value to the key.</p></dd>
<dt><a name="13"><i class="arg">graphName</i> <b class="method">arc source</b> <i class="arg">arc</i></a></dt>
<dd><p>Return the node the given <i class="arg">arc</i> begins at.</p></dd>
<dt><a name="14"><i class="arg">graphName</i> <b class="method">arc target</b> <i class="arg">arc</i></a></dt>
<dd><p>Return the node the given <i class="arg">arc</i> ends at.</p></dd>
<dt><a name="15"><i class="arg">graphName</i> <b class="method">arc unset</b> <i class="arg">arc</i> <span class="opt">?-key <i class="arg">key</i>?</span></a></dt>
<dd><p>Remove a keyed value from the arc <i class="arg">arc</i>.  If no key is specified,
the key <b class="const">data</b> is assumed.</p></dd>
<dt><a name="16"><i class="arg">graphName</i> <b class="method">arcs</b> <span class="opt">?-key <i class="arg">key</i>?</span> <span class="opt">?-value <i class="arg">value</i>?</span> <span class="opt">?-in|-out|-adj|-inner|-embedding <i class="arg">nodelist</i>?</span></a></dt>
<dd><p>Return a list of arcs in the graph. If no restriction is specified a
list containing all arcs is returned. Restrictions can limit the list
of returned arcs based on the nodes that are connected by the arc, on
the keyed values associated with the arc, or both. The restrictions
that involve connected nodes have a list of nodes as argument,
specified after the name of the restriction itself.</p>
<dl class="doctools_definitions">
<dt><b class="option">-in</b></dt>
<dd><p>Return a list of all arcs whose target is one of the nodes in the
<i class="arg">nodelist</i>.</p></dd>
<dt><b class="option">-out</b></dt>
<dd><p>Return a list of all arcs whose source is one of the nodes in the
<i class="arg">nodelist</i>.</p></dd>
<dt><b class="option">-adj</b></dt>
<dd><p>Return a list of all arcs adjacent to at least one of the nodes in the
<i class="arg">nodelist</i>. This is the union of the nodes returned by
<b class="option">-in</b> and <b class="option">-out</b>.</p></dd>
<dt><b class="option">-inner</b></dt>
<dd><p>Return a list of all arcs adjacent to two of the nodes in the
<i class="arg">nodelist</i>. This is the set of arcs in the subgraph spawned by the
specified nodes.</p></dd>
<dt><b class="option">-embedding</b></dt>
<dd><p>Return a list of all arcs adjacent to exactly one of the nodes in the
<i class="arg">nodelist</i>. This is the set of arcs connecting the subgraph
spawned by the specified nodes to the rest of the graph.</p></dd>
<dt><b class="option">-key</b> <i class="arg">key</i></dt>
<dd><p>Limit the list of arcs that are returned to those arcs that have an
associated key <i class="arg">key</i>.</p></dd>
<dt><b class="option">-value</b> <i class="arg">value</i></dt>
<dd><p>This restriction can only be used in combination with
<b class="option">-key</b>. It limits the list of arcs that are returned to those
arcs whose associated key <i class="arg">key</i> has the value <i class="arg">value</i>.</p></dd>
</dl>
<p>The restrictions imposed by either <b class="option">-in</b>, <b class="option">-out</b>,
<b class="option">-adj</b>, <b class="option">-inner</b>, or <b class="option">-embedded</b> are applied
first. Specifying more than one of them is illegal.
At last the restrictions set via <b class="option">-key</b> (and <b class="option">-value</b>)
are applied.
Specifying more than one <b class="option">-key</b> (and <b class="option">-value</b>) is
illegal.</p></dd>
<dt><a name="17"><i class="arg">graphName</i> <b class="method">node append</b> <i class="arg">node</i> <span class="opt">?-key <i class="arg">key</i>?</span> <i class="arg">value</i></a></dt>
<dd><p>Appends a <i class="arg">value</i> to one of the keyed values associated with an
<i class="arg">node</i>. If no <i class="arg">key</i> is specified, the key <b class="const">data</b> is
assumed.</p></dd>
<dt><a name="18"><i class="arg">graphName</i> <b class="method">node degree</b> <span class="opt">?-in|-out?</span> <i class="arg">node</i></a></dt>
<dd><p>Return the number of arcs adjacent to the specified <i class="arg">node</i>. If one
of the restrictions <b class="option">-in</b> or <b class="option">-out</b> is given only the
incoming resp. outgoing arcs are counted.</p></dd>
<dt><a name="19"><i class="arg">graphName</i> <b class="method">node delete</b> <i class="arg">node</i> <span class="opt">?<i class="arg">node</i> ...?</span></a></dt>
<dd><p>Remove the specified nodes from the graph.  All of the nodes' arcs
will be removed as well to prevent unconnected arcs.</p></dd>
<dt><a name="20"><i class="arg">graphName</i> <b class="method">node exists</b> <i class="arg">node</i></a></dt>
<dd><p>Return true if the specified <i class="arg">node</i> exists in the graph.</p></dd>
<dt><a name="21"><i class="arg">graphName</i> <b class="method">node get</b> <i class="arg">node</i> <span class="opt">?-key <i class="arg">key</i>?</span></a></dt>
<dd><p>Return the value associated with the key <i class="arg">key</i> for the <i class="arg">node</i>.
If no key is specified, the key <b class="const">data</b> is assumed.</p></dd>
<dt><a name="22"><i class="arg">graphName</i> <b class="method">node getall</b> <i class="arg">node</i></a></dt>
<dd><p>Returns a serialized list of key/value pairs (suitable for use with
[<b class="cmd">array set</b>]) for the <i class="arg">node</i>.</p></dd>
<dt><a name="23"><i class="arg">graphName</i> <b class="method">node keys</b> <i class="arg">node</i></a></dt>
<dd><p>Returns a list of keys for the <i class="arg">node</i>.</p></dd>
<dt><a name="24"><i class="arg">graphName</i> <b class="method">node keyexists</b> <i class="arg">node</i> <span class="opt">?-key <i class="arg">key</i>?</span></a></dt>
<dd><p>Return true if the specified <i class="arg">key</i> exists for the <i class="arg">node</i>. If
no <i class="arg">key</i> is specified, the key <b class="const">data</b> is assumed.</p></dd>
<dt><a name="25"><i class="arg">graphName</i> <b class="method">node insert</b> <span class="opt">?<i class="arg">child</i>?</span></a></dt>
<dd><p>Insert a node named <i class="arg">child</i> into the graph. The nodes has no arcs
connected to it. If the name of the new child is not specified the
system will generate a unique name of the form <em>node</em><i class="arg">x</i>.</p></dd>
<dt><a name="26"><i class="arg">graphName</i> <b class="method">node lappend</b> <i class="arg">node</i> <span class="opt">?-key <i class="arg">key</i>?</span> <i class="arg">value</i></a></dt>
<dd><p>Appends a <i class="arg">value</i> (as a list) to one of the keyed values
associated with an <i class="arg">node</i>. If no <i class="arg">key</i> is specified, the key
<b class="const">data</b> is assumed.</p></dd>
<dt><a name="27"><i class="arg">graphName</i> <b class="method">node opposite</b> <i class="arg">node</i> <i class="arg">arc</i></a></dt>
<dd><p>Return the node at the other end of the specified <i class="arg">arc</i>, which has
to be adjacent to the given <i class="arg">node</i>.</p></dd>
<dt><a name="28"><i class="arg">graphName</i> <b class="method">node set</b> <i class="arg">node</i> <span class="opt">?-key <i class="arg">key</i>?</span> <span class="opt">?<i class="arg">value</i>?</span></a></dt>
<dd><p>Set or get one of the keyed values associated with a node.  If no key
is specified, the key <b class="const">data</b> is assumed.  Each node that is
added to a graph has the empty string assigned to the key
<b class="const">data</b> automatically.  A node may have any number of keyed
values associated with it.  If <i class="arg">value</i> is not specified, this
command returns the current value assigned to the key; if <i class="arg">value</i>
is specified, this command assigns that value to the key.</p></dd>
<dt><a name="29"><i class="arg">graphName</i> <b class="method">node unset</b> <i class="arg">node</i> <span class="opt">?-key <i class="arg">key</i>?</span></a></dt>
<dd><p>Remove a keyed value from the node <i class="arg">node</i>.  If no key is
specified, the key <b class="method">data</b> is assumed.</p></dd>
<dt><a name="30"><i class="arg">graphName</i> <b class="method">nodes</b> <span class="opt">?-key <i class="arg">key</i>?</span> <span class="opt">?-value <i class="arg">value</i>?</span> <span class="opt">?-in|-out|-adj|-inner|-embedding <i class="arg">nodelist</i>?</span></a></dt>
<dd><p>Return a list of nodes in the graph. Restrictions can limit the list
of returned nodes based on neighboring nodes, or based on the keyed
values associated with the node. The restrictions that involve
neighboring nodes have a list of nodes as argument, specified after
the name of the restriction itself.</p>
<p>The possible restrictions are the same as for method
<b class="method">arcs</b>. The set of nodes to return is computed as the union of
all source and target nodes for all the arcs satisfying the
restriction as defined for <b class="method">arcs</b>.</p></dd>
<dt><a name="31"><i class="arg">graphName</i> <b class="method">get</b> <span class="opt">?-key <i class="arg">key</i>?</span></a></dt>
<dd><p>Return the value associated with the key <i class="arg">key</i> for the graph. If
no key is specified, the key <b class="const">data</b> is assumed.</p></dd>
<dt><a name="32"><i class="arg">graphName</i> <b class="method">getall</b></a></dt>
<dd><p>Returns a serialized list of key/value pairs (suitable for use with
[<b class="cmd">array set</b>]) for the whole graph.</p></dd>
<dt><a name="33"><i class="arg">graphName</i> <b class="method">keys</b></a></dt>
<dd><p>Returns a list of keys for the whole graph.</p></dd>
<dt><a name="34"><i class="arg">graphName</i> <b class="method">keyexists</b> <span class="opt">?-key <i class="arg">key</i>?</span></a></dt>
<dd><p>Return true if the specified <i class="arg">key</i> exists for the whole graph. If no
<i class="arg">key</i> is specified, the key <b class="const">data</b> is assumed.</p></dd>
<dt><a name="35"><i class="arg">graphName</i> <b class="method">set</b> <span class="opt">?-key <i class="arg">key</i>?</span> <span class="opt">?<i class="arg">value</i>?</span></a></dt>
<dd><p>Set or get one of the keyed values associated with a graph. If no key
is specified, the key <b class="const">data</b> is assumed. Each graph has the
empty string assigned to the key <b class="const">data</b> automatically. A graph
may have any number of keyed values associated with it. If <i class="arg">value</i>
is not specified, this command returns the current value assigned to
the key; if <i class="arg">value</i> is specified, this command assigns that value
to the key.</p></dd>
<dt><a name="36"><i class="arg">graphName</i> <b class="method">swap</b> <i class="arg">node1</i> <i class="arg">node2</i></a></dt>
<dd><p>Swap the position of <i class="arg">node1</i> and <i class="arg">node2</i> in the graph.</p></dd>
<dt><a name="37"><i class="arg">graphName</i> <b class="method">unset</b> <span class="opt">?-key <i class="arg">key</i>?</span></a></dt>
<dd><p>Remove a keyed value from the graph. If no key is specified, the key
<b class="const">data</b> is assumed.</p></dd>
<dt><a name="38"><i class="arg">graphName</i> <b class="method">walk</b> <i class="arg">node</i> <span class="opt">?-order <i class="arg">order</i>?</span> <span class="opt">?-type <i class="arg">type</i>?</span> <span class="opt">?-dir <i class="arg">direction</i>?</span> -command <i class="arg">cmd</i></a></dt>
<dd><p>Perform a breadth-first or depth-first walk of the graph starting at
the node <i class="arg">node</i> going in either the direction of outgoing or
opposite to the incoming arcs.</p>
<p>The type of walk, breadth-first or depth-first, is determined by the
value of <i class="arg">type</i>; <b class="const">bfs</b> indicates breadth-first,
<b class="const">dfs</b> indicates depth-first.  Depth-first is the default.</p>
<p>The order of the walk, pre-order, post-order or both-order is
determined by the value of <i class="arg">order</i>; <b class="const">pre</b> indicates
pre-order, <b class="const">post</b> indicates post-order, <b class="const">both</b> indicates
both-order. Pre-order is the default. Pre-order walking means that a
node is visited before any of its neighbors (as defined by the
<i class="arg">direction</i>, see below). Post-order walking means that a parent is
visited after any of its neighbors. Both-order walking means that a
node is visited before <em>and</em> after any of its neighbors. The
combination of a bread-first walk with post- or both-order is illegal.</p>
<p>The direction of the walk is determined by the value of <i class="arg">dir</i>;
<b class="const">backward</b> indicates the direction opposite to the incoming
arcs, <b class="const">forward</b> indicates the direction of the outgoing arcs.</p>
<p>As the walk progresses, the command <i class="arg">cmd</i> will be evaluated at
each node, with the mode of the call (<b class="const">enter</b> or
<b class="const">leave</b>) and values <i class="arg">graphName</i> and the name of the current
node appended. For a pre-order walk, all nodes are <b class="const">enter</b>ed, for a
post-order all nodes are left. In a both-order walk the first visit of
a node <b class="const">enter</b>s it, the second visit <b class="const">leave</b>s it.</p></dd>
</dl>
</div>
<div id="section2" class="doctools_section"><h2><a name="section2">Bugs, Ideas, Feedback</a></h2>
<p>This document, and the package it describes, will undoubtedly contain
bugs and other problems.
Please report such in the category <em>struct :: graph</em> of the
<a href="http://core.tcl.tk/tcllib/reportlist">Tcllib Trackers</a>.
Please also report any ideas for enhancements you may have for either
package and/or documentation.</p>
<p>When proposing code changes, please provide <em>unified diffs</em>,
i.e the output of <b class="const">diff -u</b>.</p>
<p>Note further that <em>attachments</em> are strongly preferred over
inlined patches. Attachments can be made by going to the <b class="const">Edit</b>
form of the ticket immediately after its creation, and then using the
left-most button in the secondary navigation bar.</p>
</div>
<div id="keywords" class="doctools_section"><h2><a name="keywords">Keywords</a></h2>
<p><a href="../../../../index.html#cgraph">cgraph</a>, <a href="../../../../index.html#graph">graph</a></p>
</div>
<div id="category" class="doctools_section"><h2><a name="category">Category</a></h2>
<p>Data structures</p>
</div>
<div id="copyright" class="doctools_section"><h2><a name="copyright">Copyright</a></h2>
<p>Copyright &copy; 2002 Andreas Kupries &lt;andreas_kupries@users.sourceforge.net&gt;</p>
</div>
</div></body></html>
